package com.whisperarts.financer.app.editors;

import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;

public class NameEditingSupport extends EditingSupport {

	private final TableViewer viewer;

	public NameEditingSupport(TableViewer viewer) {
		super(viewer);
		this.viewer = viewer;
	}

	@Override
	protected CellEditor getCellEditor(Object element) {
		return new TextCellEditor(viewer.getTable());
	}

	@Override
	protected boolean canEdit(Object element) {
		return true;
	}

	@Override
	protected Object getValue(Object element) {
//		return ((Transaction) element).getName();
		return "123";
	}

	@Override
	protected void setValue(Object element, Object value) {
//		((Transaction) element).setName(String.valueOf(value));
		viewer.refresh();
	}
}